<?php

namespace  App\Http\Controllers\V1;

use App\Helpers\RestResponseFactory;
use App\Helpers\RestUtils;
use App\Http\Controllers\Controller;
use App\Models\Factory\SmsFactory;
use App\Models\Factory\UserFactory;
use App\Models\Orm\Banner;
use App\Models\Orm\Config;
use App\Models\Orm\Exchange;
use App\Models\Orm\UserIncome;
use App\Services\Core\Sms\Dahan\DahanService;
use Illuminate\Http\Request;
/**
 * Class GeetesController
 * @package App\Http\Controllers\V1
 * 短信
 */
class ProfitController extends  Controller
{

    /**
     * 发送短信
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function profit(Request $request)
    {
        //拿到中间件里赋值的userId
        $user = $request -> get('user');

        $data = UserIncome::where('user_id',$user->id)->first()->toArray();
        $data['total_numer'] = $data['person_number'] + $data['team_number'];
        $data['total_income'] = $user ->total;
        $data['register_income'] = 70;

        return RestResponseFactory::ok($data,200);

    }



    public function profitTotal(Request $request)
    {
        //拿到中间件里赋值的userId
        $user = $request -> get('user');
        $data = UserIncome::where('user_id',$user->id)->first()->toArray();
        $result['total_income'] = $user->total;
        $exchange = Exchange::limit(1)->get();
        $result['exchange'] = count($exchange) ? $exchange[0]['number'] : 0 ;
        $result['total_eth'] = $user->total_bi;
        $config = Config::limit(1)->get();
        $result['private_number'] = count($config) ? $config[0]['private_number'] : 0;
        $result['exchange_number'] = count($config) ?$config[0]['exchange_number'] : 0;
        $result['stage'] = count($config) ?$config[0]['stage'] : 0;
        $result['private'] = [
            "5.15~6.15、7000、1EHT = 700", '6.16~7.16、6000、1EHT = 600', '7.17~8.17、4000、1EHT = 500','8.18~9.18、3000、1EHT = 400'
        ];
        $result['private_value'] = [ "700",  "600",  "500",  "400"];

        return RestResponseFactory::ok($result,200);

    }


}